/**
 * 
 */
package com.gopay.bis.cmb.ebank.impl;


import com.gopay.bis.cmb.ebank.operation.CmbB2cCerthelper;
import com.gopay.bis.cmb.ebank.operation.CmbB2cQueryHelper;
import com.gopay.common.constants.bank.CmbConstants;
import com.gopay.common.domain.bank.BaseMessage;
import com.gopay.common.domain.bank.cmb.ebank.pay.CmbB2cMessage;
import com.gopay.common.domain.bank.cmb.ebank.query.CmbB2cResMessage;
import com.gopay.common.exception.GopayException;
import com.gopay.remote.bank.businesses.BankService;

/**
 * @CmbB2cBankServiceImpl.java
 * @author Ryan
 * @2013-10-29 上午10:50:08 www.gopay.com.cn Inc.All rights reserved.
 */
public class CmbB2cBankServiceImpl implements BankService {

    private CmbB2cCerthelper cmbB2cCerthelper;

    private CmbB2cQueryHelper cmbB2cQueryHelper;

    public Object sign(BaseMessage msg) throws GopayException {
        CmbB2cMessage cmbB2cMessage = (CmbB2cMessage) msg;
        return cmbB2cCerthelper.sign(cmbB2cMessage);
    }

    public Object verify(BaseMessage msg) throws GopayException {
        CmbB2cMessage cmbB2cMessage = (CmbB2cMessage) msg;
        return cmbB2cCerthelper.verify(cmbB2cMessage);
    }

    public Object query(Object obj) throws GopayException {
            CmbB2cMessage message = (CmbB2cMessage) obj;
            CmbB2cResMessage messageResult=null;        
//            boolean isLogin = cmbB2cQueryHelper.login(message.getBranchID(), message.getCoNo(), message.getPrivatePwd());
//            if(isLogin){
                messageResult = cmbB2cQueryHelper.query(message);
                if(CmbConstants.CMB_QUERY_STATUS_SUCCESS_INT.equals(messageResult.getQueryResult())){
                    cmbB2cQueryHelper.parseToMessage(messageResult,messageResult.getStrBuf().toString());
                }
//            }
            return messageResult;
    }

    public void setCmbB2cCerthelper(CmbB2cCerthelper cmbB2cCerthelper) {
        this.cmbB2cCerthelper = cmbB2cCerthelper;
    }

    /**
     * @param cmbB2cQueryHelper the cmbB2cQueryHelper to set
     */
    public void setCmbB2cQueryHelper(CmbB2cQueryHelper cmbB2cQueryHelper) {
        this.cmbB2cQueryHelper = cmbB2cQueryHelper;
    }

	@Override
	public Object dayend(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object refund(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

}
